﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Kargo3504.Paneller;

namespace Kargo3504
{
    public partial class FrmAnaForm : Form
    {
        public FrmAnaForm()
        {
            InitializeComponent();
            FrmLogin ff = new FrmLogin();
            ff.ShowDialog();
        }
        public static Kullanicilar GirisYapanKullanici { get; set; }
        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (Control item in flowLayoutPanel1.Controls)
            {
                if (item is GroupBox)
                {
                    item.Visible = false;
                    item.Height = 20;
                    item.MouseClick += new MouseEventHandler(item_MouseClick);
                }
            }
            switch (GirisYapanKullanici.KullaniciYetkileri.KullaniciYetkiAdi)
            {
                case "Admin":
                    pnlAdmin.Visible = true;
                    pnlYonetici.Visible = true;
                    pnlOperator.Visible = true;
                    break;
                case "Yönetici":
                    pnlYonetici.Visible = true;
                    pnlOperator.Visible = true;
                    break;
                case "Operatör":
                    pnlOperator.Visible = true;
                    break;
            }
        }

        void item_MouseClick(object sender, MouseEventArgs e)
        {
            foreach (Control item in flowLayoutPanel1.Controls)
            {
                if (item is GroupBox)
                {

                    item.Height = 20;
                }
            }
            GroupBox gg = sender as GroupBox;
            int ElemanSayisi = gg.Controls.Count;
            int ToplamButtonYukseklik = ElemanSayisi * 25;
            int ToplamBoslukYukseklik = (ElemanSayisi - 1) * 3;
            gg.Height = ToplamButtonYukseklik + ToplamBoslukYukseklik + 30;
        }

        private void btnCalismaAlaniTanimlama_Click(object sender, EventArgs e)
        {
            PanelleriTemizle();
            CalismaAlaniTanimlamaFormu cc = new CalismaAlaniTanimlamaFormu();
            pnlSabitAlan.Controls.Add(cc);
        }

        void PanelleriTemizle()
        {
            pnlSabitAlan.Controls.Clear();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            PanelleriTemizle();
            BirimTanimlamaFormu cc = new BirimTanimlamaFormu();
            pnlSabitAlan.Controls.Add(cc);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            PanelleriTemizle();
            KullaniciIslemler ki = new KullaniciIslemler();
            pnlSabitAlan.Controls.Add(ki);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            PanelleriTemizle();
            MusteriTanimla mt = new MusteriTanimla();
            pnlSabitAlan.Controls.Add(mt);
        }
    }
}
